
package copytranslation.read;

import copytranslation.hash.Hash;
import java.io.File;

/**
 *
 * @author srkrishnan
 */
public class ReadExcel {

    private String srcexcelPath;
    
    private int KeyColumnindex;
    private int valueColumnindex;

    public ReadExcel() {
    }

    public ReadExcel(String srcexcelPath) {
        this.srcexcelPath = srcexcelPath;
     }

    public ReadExcel(String srcexcelPath, int KeyRowindex, int valueRowindex) {
        this.srcexcelPath = srcexcelPath;
        this.KeyColumnindex = KeyRowindex;
        this.valueColumnindex = valueRowindex;
    }

    public int getKeyColumnindex() {
        return KeyColumnindex;
    }

    public void setKeyColumnindex(int KeyRowindex) {
        this.KeyColumnindex = KeyRowindex;
    }

    public int getValueColumnindex() {
        return valueColumnindex;
    }

    public void setValueColumnindex(int valueRowindex) {
        this.valueColumnindex = valueRowindex;
    }

    public String getSrcexcelPath() {
        return srcexcelPath;
    }

    public void setSrcexcelPath(String srcexcelPath) {
        this.srcexcelPath = srcexcelPath;
    }

    public void buildHash() {
        processFolder(srcexcelPath);
        
    }

    /*
     * process the given folder recursively
     */
    private void processFolder(String filepath) {
        File file = new File(filepath);
        if (!file.exists()) {
            return;
        }
        //If not directory
        if (!file.isDirectory()) {
            //System.out.println("Processing.... " + file.getName());
            if (file.getName().endsWith(".xls") || file.getName().endsWith(".XLS")) {
                Hash.addtoHeap(file,this);
            }
            return;
        }
        String[] filelist = file.list();
        for (String filename : filelist) {
            processFolder(filepath + File.separator + filename);
        }
    }
}
